package com.haipi.time;

import java.util.List;
import java.util.TimerTask;

import javax.annotation.Resource;

import com.haipi.model.CommInitial;
import com.haipi.model.MailInfo;
import com.haipi.service.IMailService;
import com.haipi.util.mail.MailUtil;
public class CommMail extends TimerTask
{
	@Resource
	IMailService mailService ;

	@Override
	public void run()
	{
		System.out.print("run()...........");
		List<MailInfo> mails = mailService.getSendMaiList();
		String key = "";
		for (int i = 0; i < mails.size(); i++)
		{
		    if ("0".equals(mails.get(i).getRemindType()))
            {
                key = "comm.remind";
            }
            else
            {
                key = "record.remind";
            }
			MailUtil.send("沟通管理系统提示信息", (String)CommInitial.initialParamMap.get(key), mails.get(i).getAddressee());
//			mailBoxService.deleteMail(mails.get(i).getId());
		}
		try
		{
			Thread.sleep(5000);
		} catch (InterruptedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
